package top.loonglove.bean;

import top.loonglove.status.ElementType;

import java.util.Objects;

/**
 * @author 向贵龙
 * @date 2021/7/12
 * 超链接标签
 */
public class HyperlinksElement extends AbstractElement{
    /**
     * 超链接地址
     */
    private String url;

    public HyperlinksElement(String value, String url) {
        super(value);
        this.url = url;
        this.type = ElementType.Hyperlinks;
    }

    public HyperlinksElement() {
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public HyperlinksElement(String value, String url, ElementType type) {
        super(value, type);
        this.url = url;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        HyperlinksElement that = (HyperlinksElement) o;
        return Objects.equals(url, that.url);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), url);
    }

    @Override
    public String toString() {
        return String.format("[%s](%s)",value,url);
    }
}
